package com.study.array;

/**
 * @author ZhaoDong
 * @date 2022/8/15 9:44
 * @description 删除排序数组中的重复项
 */
public class Test1 {
    public static void main(String[] args) {
        int i = removeDuplicates(new int[]{0, 0, 1, 1, 1, 2, 2, 3, 3, 4});
        System.out.println(i);
    }

    public static int removeDuplicates(int[] nums) {

        int slow = 1;
        for (int i = 1; i < nums.length; i++) {
            int num = nums[i];
            if (num > nums[slow - 1]) {

                nums[slow] = num;
                slow++;
            }
        }
        return slow;
    }
}
